import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.*;

public class DownloadThread extends Thread {
	HttpGet ht;
	String s="http://energy32.ucd.ie/areas/Belfield/logs/zip_logs/";
	String x="_elec15.zip";
	Semaphore a,b,c;  
	public DownloadThread(HttpGet hp,Semaphore a1,Semaphore a2,Semaphore a3){
		ht=hp;
		a=a1;b=a2;c=a3;
	}
	public void run(){
		
		    readTex("link.txt");
		    ht.addItem(s+"hsci_p1NO_MBRSelec15.zip","hsci_p1NO_MBRS.zip");
		    ht.addItem(s+"hsci_p2elec15.zip","hsci_p2.zip");
		    ht.downLoadByList();
		    a.release();
			try{
				
				Thread.sleep(100);
			}
			catch(InterruptedException e){
				 
			}
			
		}
		

	
	public void readTex(String v) {
		
		String lineContent = null;
	
		String ss=null;
	    try {
	      InputStream is = getClass().getResourceAsStream(v);
	      BufferedReader br = new BufferedReader
	      
	         (new InputStreamReader(is));
	      while ((lineContent = br.readLine()) != null) {
				ss=s+lineContent+x;
                ht.addItem(ss,lineContent+".zip");
               
	         }
	   
	      }
	    catch (Exception e) {
	      e.printStackTrace();
	      }
		
	  }
	
		
	}


